#pragma once
#include "protocol.hpp"


class Calculate
{
public:
    std::shared_ptr<Response> Execute(std::shared_ptr<Request> req)
    {
        
        char op = req->_op;
        int res = 0;
        int code = 0;
        switch(op)
        {
            case '+':
                res = req->_x + req->_y;
                break;
            case '-':
                res = req->_x + req->_y;
                break;
            case '*':
                res = req->_x * req->_y;
                break;
            case '/':
                if(req->_y == 0)
                {
                    code = 1;
                    break;
                }
                res = req->_x / req->_y;
                break;
        }

        return std::make_shared<Response>(res, code);
    }
};